import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '@/views/home'
import Layout from '@/views/layout'
const Search = () => import('@/views/search')
const News = () => import('@/views/news')
const User = () => import('@/views/user')
const NotFound = () => import('@/views/404')
const City = () => import('@/views/city')
const Login = () => import('@/views/login')
const Register = () => import('@/views/register')
const HouseDetail = () => import('@/views/houseDetail')
const Map = () => import('@/views/map')
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home',
    component: Layout,
    children: [
      { path: '/home', component: Home },
      { path: '/search', component: Search },
      { path: '/news', component: News },
      { path: '/user', component: User }
    ]
  },
  { path: '/layout', component: Layout, redirect: '/home' },
  { path: '/city', component: City },
  { path: '/login', component: Login },
  { path: '/register', component: Register },
  { path: '/housedetail/:id', component: HouseDetail },
  { path: '/map', component: Map },
  { path: '*', component: NotFound }
]

const router = new VueRouter({
  routes
})

export default router
